//---------------------------------------------------------------------------- // File: MsgMng.h // Type: Manages Message Banks. // Author: Ken Anderson // Date: 10/24/3 // OS dependant: NA // Desc: Designed to manage a message bank. //---------------------------------------------------------------------------- #include "Common.h" ///////////////////////////// // DEFINITIONS // ///////////////////////////// typedef Word MSG_EVENT; //All Message events are Word data types. ///////////////////////////// // MSG STRUCTURE // ///////////////////////////// typedef struct tg_MSG_BLOCK { MSG_EVENT event; //The actual message. Dword value; //The value of the message. tg_MSG_BLOCK *next; //The next message in the list. } Msg, *pMsg; ///////////////////////////// // MSG BANK CLASS // ///////////////////////////// //Naming convention C markes Classes. //Use lower cases + upper case as Microsoft uses uppercase //and it is always possible to create classes with similiar names. class CMsgBank { //Class Member variables private: pMsg pMsgTail; //Bottom of the Message Bank(or Queue) [Msg Out] pMsg pMsgTop; //Top of the message Bank(or Queue) [Msg In] private: void PurgeBank(); //Cleans out the entire message bank. bool Exists(MSG_EVENT event, Dword value); public: //Constructor & destructors CMsgBank(); ~CMsgBank(); //Message Bank manipulation bool Push(pMsg msg); //Pushes a message onto the message bank. bool Push(MSG_EVENT event, Dword value); //Creates a new message void Pop(); //Pops a message off the tail end of the message bank. void CleanBank(); //Cleans, deletes all messages in, the message bank. //Querying int Depth(); //Returns the depth of the message bank. Msg GetMsg(); //Performs the same task as GetTailMsg. Msg PeekMsg(); //Get the message off the tail but does not remove it after fetching it };